package com.ciei.dpagm.controller;


import com.alibaba.fastjson.JSONObject;
import com.ciei.dpagm.common.controller.BaseController;
import com.ciei.dpagm.entity.Users;
import com.ciei.dpagm.service.ModelModuleService;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("dataModelModule")
public class DataModelModuleController extends BaseController {

	@Autowired
	private ModelModuleService modelModuleService;

	@RequestMapping("loadModelList")
	@ResponseBody
	public JSONObject loadModelList(@RequestBody JSONObject data){
		return modelModuleService.loadModelList(data);
	}

	@RequestMapping("loadModuleList")
	@ResponseBody
	public JSONObject loadModuleList(@RequestBody JSONObject data){
		return modelModuleService.loadModuleList(data);
	}

	@RequestMapping("searchDataByName")
	@ResponseBody
	public JSONObject searchDataByName(@RequestBody JSONObject data){
		return modelModuleService.searchDataByName(data);
	}

	@RequestMapping("add")
	@ResponseBody
	public JSONObject add(@RequestBody JSONObject data){
		return modelModuleService.add(data);
	}

	@RequestMapping("update")
	@ResponseBody
	public JSONObject update(@RequestBody JSONObject data){
		return modelModuleService.update(data);
	}

	@RequestMapping("delete")
	@ResponseBody
	public JSONObject delete(@RequestBody JSONObject data){
		return modelModuleService.delete(data);
	}

	@RequestMapping("copy")
	@ResponseBody
	public JSONObject copy(@RequestBody JSONObject data){
		Users currentUser = (Users) SecurityUtils.getSubject().getPrincipal();
		return modelModuleService.copy(data,currentUser);
	}

	@RequestMapping("export")
	@ResponseBody
	public JSONObject exprot(@RequestBody JSONObject data,HttpServletResponse response){
		return modelModuleService.export(data,response);
	}

}
